using System;
using System.Globalization;
using System.Windows.Data;

namespace ibba.src.sl.recursos.Converters
{
    public class DecimalConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int dec;

            if (parameter != null)
            {
                if (int.TryParse(parameter as string, out dec) != true)
                {
                    dec = 2;
                }
            }
            else
                dec = 2;

            return (((decimal)value).ToString(string.Format("n{0}",dec)));
            //return GeneralHelper.ConverterDecimal(value.ToString(), dec);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }


    }
}
